package com.srit.recipes.entity;

import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.ColumnDefault;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.util.Date;
import java.util.List;

@Table
@Entity
@Getter
@Setter
@DynamicInsert
@DynamicUpdate
@EntityListeners(AuditingEntityListener.class)
@SelectBeforeUpdate
public class WeekRecipes extends RecipesId {

    public static final int IN_CREATE = 0;
    public static final int IN_EXAMINE = 1;
    public static final int EXAMINE_FAILED = 2;
    public static final int EXAMINE_PASS = 3;
    public static final int ABANDON = 4;

    /**
     * 就餐人数， 默认100
     */
    @Column
    private Integer perNum;

    @Column
    private String recipesName;


    @CreatedDate
    @Column(nullable = false,columnDefinition = " datetime comment '创建时间'",updatable = false)
    @ApiModelProperty(example = "2020-01-01 00:00:00")
    protected Date createTime;


    @LastModifiedDate
    @Column(nullable = false,columnDefinition = " datetime comment '更新时间'")
    @ApiModelProperty(example = "2020-01-01 00:00:00")
    protected Date updateTime;

    @Transient
    private List<WeekRecipesDetail> details;

    @Column
    private String perType = "A1";

    /**
     * 0创建中 1: 审核中 2: 审核不通过 3: 审核通过
     */
    @Column
    private Integer state;

    /**
     * 采购单审核状态
     */
    @Column
    @ColumnDefault("0")
    private Integer procurementState;

    @Column
    private String examineMsg;

    @Column
    private String proExamineMsg;

    @Column
    private Integer type;
}
